/*
 *  SyncIT , easy synchronization of files between computers and devices.
 *  Copyright (C) 2011  Christian Masus <cmasus(at)gmail.com>
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version. If redistributing and/or modifying
 *  this file, this notice must be included in the redistributed or
 *  modified copy.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package config.items;

/**
 * Defines the configuration items related to the JavaGui.
 * stored under "gui/".
 * @author Christian Masus
 *
 */
public class GuiItems {

	// Default values
	private final int    DEFAULT_JAVA_SPLIT_PANE_POSITION = 100;
	private final String DEFAULT_JAVA_COLUMN_WIDTHS       = "25,50,150,120,75,150,80,110,120";
	private final String DEFAULT_JAVA_COLUMN_POSITIONS    = "0,1,2,3,4,5,6,7,8";
	private final String DEFAULT_JAVA_ROW_SORT_ORDER      = "";
	private final int DEFAULT_JAVA_ACTIVE_TAB             = 0;

	// Configuration
	private int    javaSplitPanePosition;
	private String javaColumnWidths;
	private String javaColumnPositions;
	private String javaRowSortOrder;
	private int    javaActiveTab;


	public GuiItems() {
		loadDefaultValues();
	}


	public int getJavaSplitPanePosition() {
		return javaSplitPanePosition;
	}
	public void setJavaSplitPanePosition(int javaSplitPanePosition) {
		this.javaSplitPanePosition = javaSplitPanePosition;
	}
	public void setJavaSplitPanePosition(String javaSplitPanePosition) {
		this.javaSplitPanePosition = new Integer(javaSplitPanePosition);
	}

	public String getJavaColumnWidths() {
		return javaColumnWidths;
	}
	public void setJavaColumnWidths(String javaColumnWidths) {
		this.javaColumnWidths = javaColumnWidths;
	}

	public String getJavaColumnPositions() {
		return javaColumnPositions;
	}
	public void setJavaColumnPositions(String javaColumnPositions) {
		this.javaColumnPositions = javaColumnPositions;
	}

	public String getJavaRowSortOrder() {
		return javaRowSortOrder;
	}
	public void setJavaRowSortOrder(String javaRowSortOrder) {
		this.javaRowSortOrder = javaRowSortOrder;
	}

	public int getJavaActiveTab() {
		return javaActiveTab;
	}
	public void setJavaActiveTab(int javaActiveTab) {
		this.javaActiveTab = javaActiveTab;
	}
	public void setJavaActiveTab(String javaActiveTab) {
		this.javaActiveTab = new Integer(javaActiveTab);
	}



	public void loadDefaultValues() {
		javaSplitPanePosition = DEFAULT_JAVA_SPLIT_PANE_POSITION;
		javaColumnWidths      = DEFAULT_JAVA_COLUMN_WIDTHS;
		javaColumnPositions   = DEFAULT_JAVA_COLUMN_POSITIONS;
		javaRowSortOrder      = DEFAULT_JAVA_ROW_SORT_ORDER;
		javaActiveTab         = DEFAULT_JAVA_ACTIVE_TAB;
	}

	public String[][] getTagValuePair() {
		String[][] ret = {
				{"JavaSplitPanePosition", new Integer(javaSplitPanePosition).toString()},
				{"JavaColumnWidths",      javaColumnWidths},
				{"JavaColumnPositions",   javaColumnPositions},
				{"JavaRowSortOrder",      javaRowSortOrder},
				{"JavaActiveTab",         new Integer(javaActiveTab).toString()}
		};
		return ret;
	}

	public String toString() {
		String ret = "";
		String[][] tagValuePair = getTagValuePair();
		for(int row = 0; row < tagValuePair.length; row++) {
			ret += tagValuePair[row][0] + " = " + tagValuePair[row][1] + "\n";
		}
		return ret;
	}
}
